/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.blitzcoder.collide.util;

import javax.swing.JOptionPane;

/**
 *
 * @author blitzcoder
 */
public class OS {

    private static int OS = -1;
    
    public static final int WINDOWS = 0;
    public static final int MACOSX = 1;
    public static final int LINUX = 2;
    public static final int OTHER = 3;
    
    private static String osname;
    private static String osversion;
    private static String osarch;
    
    static {
        osname = System.getProperty("os.name");
        osversion = System.getProperty("os.version");
        osarch = System.getProperty("os.arch");
        
        if (osname.toLowerCase().indexOf("windows") != -1)
            OS = WINDOWS;
        else if (osname.toLowerCase().indexOf("linux") != -1)
            OS = LINUX;
        else if (osname.toLowerCase().indexOf("mac") != -1)
            OS = MACOSX;
        else {
            OS = OTHER;
        }
        
    }
    
    public static void validateOS() {
        if (isOther()) {
            JOptionPane.showMessageDialog(null, "Entschuldigung. Dieses Programm läuft nur auf Windows, Linux und Mac OSX.");
            System.exit(0);
        }
    }
    
    public static boolean isWindows() {
        return OS == WINDOWS;
    }
    
    public static boolean isLinux() {
        return OS == LINUX;
    }
    
    public static boolean isMacOSX() {
        return OS == MACOSX;
    }
    
    public static boolean isOther() {
        return OS == OTHER;
    }

}
